﻿<Window x:Class="WMSSoft.WinKStart.Settings_NewEditAction"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Name="SettingNewAction"
        Title="{Binding ViewName}" Height="382" Width="455" ResizeMode="NoResize" ShowInTaskbar="False" WindowStartupLocation="CenterOwner" WindowStyle="ToolWindow">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="19*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="1" Orientation="Horizontal" FlowDirection="RightToLeft" >
            <Button Content="{Binding Cmd_Apply.ViewName}" Height="23" HorizontalAlignment="Right" Margin="10,10,5,5" Width="100" IsDefault="True" Command="{Binding Cmd_Apply.Command}" CommandParameter="{Binding ElementName=SettingNewAction}" HorizontalContentAlignment="Center"/>
            <Button Content="{Binding Cmd_Discard.ViewName}" Height="23" HorizontalAlignment="Right" Margin="5,10,0,5" Width="100" IsCancel="True" Command="{Binding Cmd_Discard.Command}" CommandParameter="{Binding ElementName=SettingNewAction}" />
            <Button Content="{Binding Cmd_Ok.ViewName}" Height="23" HorizontalAlignment="Right" Margin="5,10,0,5" Width="100" IsCancel="True" Command="{Binding Cmd_Ok.Command}" CommandParameter="{Binding ElementName=SettingNewAction}" />
        </StackPanel>
        <Grid Margin="10,10,10,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="25"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Label Content="Name:" HorizontalAlignment="Left" Padding="0,0,0,0" Margin="0,2,10,5" VerticalAlignment="Top"/>
            <TextBox Grid.Column="1" TextWrapping="Wrap" Margin="0,0,0,5" Text="{Binding ActionName}" VerticalContentAlignment="Center" IsEnabled="{Binding EnableNameChanging}"/>
            <Label Content="Type:" HorizontalAlignment="Left" Padding="0,0,0,0" Margin="0,7,10,5" VerticalAlignment="Top" Grid.Row="1"/>
            <ComboBox HorizontalAlignment="Left"  Margin="0,4,0,0" Grid.Row="1" Grid.Column="1" Width="252"  SelectedValue="{Binding SelectedActionType}" SelectedValuePath="Key" DisplayMemberPath="Value"  ItemsSource="{Binding ActionTypeItems}" />
            <Label Content="Event Source:" HorizontalAlignment="Left" Padding="0,0,0,0" Margin="0,7,10,5" VerticalAlignment="Top" Grid.Row="2"/>
            <ComboBox HorizontalAlignment="Left" Margin="0,4,0,0" VerticalAlignment="Top" Width="252" Grid.Column="1" Grid.Row="2" SelectedValue="{Binding SelectedEventSource}" SelectedValuePath="Key" DisplayMemberPath="Value"  ItemsSource="{Binding EventSourceItems}"/>
            <Label Content="Function:" HorizontalAlignment="Left" Padding="0,0,0,0" Margin="0,7,10,5" VerticalAlignment="Top" Grid.Row="3"/>
            <ComboBox HorizontalAlignment="Left" Margin="0,4,0,0" VerticalAlignment="Top" Width="252" Grid.Column="1" Grid.Row="3" SelectedValue="{Binding SelectedFunction}" SelectedValuePath="Key" DisplayMemberPath="Value"  ItemsSource="{Binding FunctionItems}"/>
            <Label Content="func. Arguments:" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="0,2,0,0" VerticalAlignment="Top" Grid.Row="4"/>
            <Grid Grid.Column="1" Grid.Row="4" Margin="0,5,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.Resources>
                    <ImageBrush x:Key="AddButtonImageBrush" ImageSource="/WinKStart;component/images/list-add.png" Stretch="Fill"/>
                    <ImageBrush x:Key="EditButtonImageBrush" ImageSource="/WinKStart;component/images/list-edit.png" Stretch="Fill"/>
                    <ImageBrush x:Key="DeleteButtonImageBrush" ImageSource="/WinKStart;component/images/list-remove.png" Stretch="Fill"/>
                </Grid.Resources>
                <ListView x:Name="lst_ContextUsedSourceElements" Grid.Column="0" Grid.Row="0" ItemsSource="{Binding SourceElementItems, Mode=TwoWay}" SelectedItem="{Binding SelectedSourceElement}" Margin="0">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="Element" DisplayMemberBinding="{Binding Element}" Width="100"/>                            
                            <GridViewColumn Header="Property" DisplayMemberBinding="{Binding Property}" Width="150" />
                        </GridView>
                    </ListView.View>
                </ListView>
                <StackPanel Grid.Column="1">
                    <Button Content="" Margin="5,0,0,10" Height="20" Background="{StaticResource AddButtonImageBrush}" Command="{Binding Cmd_AddSourceElement.Command}" CommandParameter="{Binding ElementName=lst_ContextUsedSourceElements}" RenderTransformOrigin="2,0"/>
                    <Button Content="" Margin="5,0,0,10" Width="20"  Background="{StaticResource EditButtonImageBrush}" Command="{Binding Cmd_EditSourceElement.Command}" CommandParameter="{Binding ElementName=lst_ContextUsedSourceElements}" IsEnabled="{Binding CanEditDeleteSourceElement}"/>
                    <Button Content="" Margin="5,0,0,10" Width="20"  Background="{StaticResource DeleteButtonImageBrush}" Command="{Binding Cmd_DeleteSourceElement.Command}" CommandParameter="{Binding ElementName=lst_ContextUsedSourceElements}" IsEnabled="{Binding CanEditDeleteSourceElement}"/>
                </StackPanel>
            </Grid>
            <Label Content="Triggers:" HorizontalAlignment="Left" Margin="0,5,0,0" Padding="0,2,0,0" VerticalAlignment="Top" Grid.Row="5"/>
            <Grid Grid.Column="1" Grid.Row="5" Margin="0,5,0,0">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                <Grid.Resources>
                    <ImageBrush x:Key="AddButtonImageBrush" ImageSource="/WinKStart;component/images/list-add.png" Stretch="Fill"/>
                    <ImageBrush x:Key="EditButtonImageBrush" ImageSource="/WinKStart;component/images/list-edit.png" Stretch="Fill"/>
                    <ImageBrush x:Key="DeleteButtonImageBrush" ImageSource="/WinKStart;component/images/list-remove.png" Stretch="Fill"/>
                </Grid.Resources>
                <ListView x:Name="lst_ContextUsedTriggers" Grid.Column="0" Grid.Row="0" ItemsSource="{Binding UsedTriggerItems, Mode=TwoWay}" SelectedItem="{Binding SelectedTrigger}" Margin="0">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn Header="Event" DisplayMemberBinding="{Binding Event}" Width="100"/>
                            <GridViewColumn Header="Value" DisplayMemberBinding="{Binding Value}" Width="90" />
                            <GridViewColumn Header="DataLength" DisplayMemberBinding="{Binding DataLength}" Width="90" />
                        </GridView>
                    </ListView.View>
                </ListView>
                <StackPanel Grid.Column="1">
                    <Button  Content="" Margin="5,0,0,10" Height="20" Background="{StaticResource AddButtonImageBrush}" Command="{Binding Cmd_AddTrigger.Command}" CommandParameter="{Binding ElementName=lst_ContextUsedTriggers}" RenderTransformOrigin="2,0"/>
                    <Button  Content="" Margin="5,0,0,10" Height="20" Background="{StaticResource EditButtonImageBrush}" Command="{Binding Cmd_EditTrigger.Command}" CommandParameter="{Binding ElementName=lst_ContextUsedTriggers}" RenderTransformOrigin="2,0"/>
                    <Button Content="" Margin="5,0,0,10" Width="20"  Background="{StaticResource DeleteButtonImageBrush}" Command="{Binding Cmd_DeleteTrigger.Command}" CommandParameter="{Binding ElementName=lst_ContextUsedTriggers}" IsEnabled="{Binding CanEditDeleteTrigger}"/>
                </StackPanel>
            </Grid>
        </Grid>
    </Grid>
</Window>
